"""
公司信息相关的 Pydantic 模式
"""
from typing import Optional
from pydantic import BaseModel, Field, EmailStr
from datetime import datetime


class CompanyInfoBase(BaseModel):
    """公司信息基础模式"""
    company_name: str = Field(..., max_length=200, description="公司名称")
    company_logo: Optional[str] = Field(None, max_length=500, description="公司Logo")
    about_us_image: Optional[str] = Field(None, max_length=500, description="关于我们页面图片")
    company_slogan: Optional[str] = Field(None, max_length=500, description="公司标语")
    company_description: Optional[str] = Field(None, description="公司简介")

    # 统计卡片字段
    stat1_title: Optional[str] = Field(None, max_length=100, description="统计卡片1标题")
    stat1_value: Optional[str] = Field(None, max_length=50, description="统计卡片1数值")
    stat2_title: Optional[str] = Field(None, max_length=100, description="统计卡片2标题")
    stat2_value: Optional[str] = Field(None, max_length=50, description="统计卡片2数值")
    stat3_title: Optional[str] = Field(None, max_length=100, description="统计卡片3标题")
    stat3_value: Optional[str] = Field(None, max_length=50, description="统计卡片3数值")
    stat4_title: Optional[str] = Field(None, max_length=100, description="统计卡片4标题")
    stat4_value: Optional[str] = Field(None, max_length=50, description="统计卡片4数值")

    company_introduction: Optional[str] = Field(None, description="公司详细介绍")
    company_vision: Optional[str] = Field(None, description="企业愿景")
    company_mission: Optional[str] = Field(None, description="企业使命")
    company_values: Optional[str] = Field(None, description="核心价值观")

    # 保留原有字段以兼容
    description: Optional[str] = Field(None, description="公司简介（旧）")
    history: Optional[str] = Field(None, description="公司历史")
    culture: Optional[str] = Field(None, description="企业文化")
    vision: Optional[str] = Field(None, description="发展愿景（旧）")
    address: Optional[str] = Field(None, max_length=500, description="公司地址")
    phone: Optional[str] = Field(None, max_length=50, description="联系电话")
    email: Optional[str] = Field(None, max_length=100, description="邮箱")
    fax: Optional[str] = Field(None, max_length=50, description="传真")
    website: Optional[str] = Field(None, max_length=200, description="网站")
    business_license: Optional[str] = Field(None, max_length=100, description="营业执照号")
    established_date: Optional[str] = Field(None, max_length=50, description="成立时间（旧）")
    registered_capital: Optional[str] = Field(None, max_length=100, description="注册资本")


class CompanyInfoCreate(CompanyInfoBase):
    """创建公司信息请求模式"""
    class Config:
        json_schema_extra = {
            "example": {
                "company_name": "贵州青鸿生态环境咨询服务有限公司",
                "company_logo": "/images/company-logo.png",
                "company_slogan": "专业环境工程咨询，守护绿色未来",
                "company_description": "我们是一家专业的环境工程咨询公司，致力于为客户提供全方位的环境解决方案。",
                "stat1_title": "年行业经验",
                "stat1_value": "25+",
                "stat2_title": "完成项目",
                "stat2_value": "500",
                "stat3_title": "专业团队",
                "stat3_value": "50-100人",
                "stat4_title": "客户满意度",
                "stat4_value": "100%",
                "company_introduction": "我公司成立于2000年，是一家集工程建设、设计、咨询、监理于一体的综合性环境工程企业。",
                "company_vision": "成为国内领先的环境工程咨询服务提供商",
                "company_mission": "为客户提供专业、高效、可持续的环境解决方案",
                "company_values": "专业,诚信,创新,责任,合作",
                "address": "贵州省贵阳市观山湖区",
                "phone": "0851-12345678",
                "email": "info@gzqhsz.com",
                "website": "www.gzqhsz.com"
            }
        }


class CompanyInfoUpdate(BaseModel):
    """更新公司信息请求模式"""
    company_name: Optional[str] = Field(None, max_length=200, description="公司名称")
    company_logo: Optional[str] = Field(None, max_length=500, description="公司Logo")
    about_us_image: Optional[str] = Field(None, max_length=500, description="关于我们页面图片")
    company_slogan: Optional[str] = Field(None, max_length=500, description="公司标语")
    company_description: Optional[str] = Field(None, description="公司简介")

    # 统计卡片字段
    stat1_title: Optional[str] = Field(None, max_length=100, description="统计卡片1标题")
    stat1_value: Optional[str] = Field(None, max_length=50, description="统计卡片1数值")
    stat2_title: Optional[str] = Field(None, max_length=100, description="统计卡片2标题")
    stat2_value: Optional[str] = Field(None, max_length=50, description="统计卡片2数值")
    stat3_title: Optional[str] = Field(None, max_length=100, description="统计卡片3标题")
    stat3_value: Optional[str] = Field(None, max_length=50, description="统计卡片3数值")
    stat4_title: Optional[str] = Field(None, max_length=100, description="统计卡片4标题")
    stat4_value: Optional[str] = Field(None, max_length=50, description="统计卡片4数值")

    company_introduction: Optional[str] = Field(None, description="公司详细介绍")
    company_vision: Optional[str] = Field(None, description="企业愿景")
    company_mission: Optional[str] = Field(None, description="企业使命")
    company_values: Optional[str] = Field(None, description="核心价值观")

    # 保留原有字段以兼容
    description: Optional[str] = Field(None, description="公司简介（旧）")
    history: Optional[str] = Field(None, description="公司历史")
    culture: Optional[str] = Field(None, description="企业文化")
    vision: Optional[str] = Field(None, description="发展愿景（旧）")
    address: Optional[str] = Field(None, max_length=500, description="公司地址")
    phone: Optional[str] = Field(None, max_length=50, description="联系电话")
    email: Optional[str] = Field(None, max_length=100, description="邮箱")
    fax: Optional[str] = Field(None, max_length=50, description="传真")
    website: Optional[str] = Field(None, max_length=200, description="网站")
    business_license: Optional[str] = Field(None, max_length=100, description="营业执照号")
    established_date: Optional[str] = Field(None, max_length=50, description="成立时间（旧）")
    registered_capital: Optional[str] = Field(None, max_length=100, description="注册资本")


class CompanyInfoResponse(CompanyInfoBase):
    """公司信息响应模式"""
    id: int
    created_at: datetime
    updated_at: Optional[datetime] = None

    class Config:
        from_attributes = True


class ContactInfo(BaseModel):
    """联系信息模式（用于前端显示）"""
    phone: Optional[str] = None
    email: Optional[str] = None
    fax: Optional[str] = None
    address: Optional[str] = None
    website: Optional[str] = None